package com.ruoyi.health.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.health.domain.HealthStatus;
import com.ruoyi.health.service.IHealthStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 身体状况信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/health/status")
public class HealthStatusController extends BaseController
{
    @Autowired
    private IHealthStatusService healthStatusService;

    /**
     * 查询身体状况信息列表
     */
    @PreAuthorize("@ss.hasPermi('health:status:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthStatus healthStatus)
    {
        startPage();
        List<HealthStatus> list = healthStatusService.selectHealthStatusList(healthStatus);
        return getDataTable(list);
    }

    /**
     * 导出身体状况信息列表
     */
    @PreAuthorize("@ss.hasPermi('health:status:export')")
    @Log(title = "身体状况信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthStatus healthStatus)
    {
        List<HealthStatus> list = healthStatusService.selectHealthStatusList(healthStatus);
        ExcelUtil<HealthStatus> util = new ExcelUtil<HealthStatus>(HealthStatus.class);
        util.exportExcel(response, list, "身体状况信息数据");
    }

    /**
     * 获取身体状况信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:status:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthStatusService.selectHealthStatusById(id));
    }

    /**
     * 新增身体状况信息
     */
    @PreAuthorize("@ss.hasPermi('health:status:add')")
    @Log(title = "身体状况信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthStatus healthStatus)
    {
        return toAjax(healthStatusService.insertHealthStatus(healthStatus));
    }

    /**
     * 修改身体状况信息
     */
    @PreAuthorize("@ss.hasPermi('health:status:edit')")
    @Log(title = "身体状况信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthStatus healthStatus)
    {
        return toAjax(healthStatusService.updateHealthStatus(healthStatus));
    }

    /**
     * 删除身体状况信息
     */
    @PreAuthorize("@ss.hasPermi('health:status:remove')")
    @Log(title = "身体状况信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(healthStatusService.deleteHealthStatusByIds(ids));
    }
}
